<!DOCTYPE html>
<html>
<link href="ui/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="ui/css/bootstrap-themes.css" rel="stylesheet" type="text/css">
<link href="ui/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="ui/js/npm.js"></script>
<script type="text/javascript" src="ui/js/bootstrap.js"></script>
<script type="text/javascript" src="ui/js/bootstrap.min.js"></script>
<head>
	<meta charset="utf-8">
	<title>Admin Login</title>
	<link rel="stylesheet" type="text/css" href="public.css">
</head>
<body>

	<script type="text/javascript">
		function adminLogin() {
			var username = document.getElementById('username').value;
			var password = document.getElementById('password').value;
			// 管理员登录
			var data = {
				"username": username,
				"password": password
			}

			return data;
		}

		function ajax_method(url, data) {
			  var xhr = new XMLHttpRequest();
			  
			  xhr.onreadystatechange = function() {
			    if(xhr.readyState==4 && xhr.status==200) {
			        var data = JSON.parse(xhr.responseText);
			        if (data.code == 200) {                   
			            window.location.href="addCompactDisk.html";
			        } else {
			            alert(data.state);
			        }
			    }
			  }

			  xhr.open("POST", url, true);		  
			  xhr.setRequestHeader("Content-Type","application/json");
			  xhr.send(JSON.stringify(data));
		}
	</script>
	<div class="jumbotron">
		<h1>影碟出租管理系统后台登录</h1>
		<p>Video rental Management System</p>
	</div>
	<form>
		用户名:<br>
		<input type="text" id="username"><br>
		密码:<br>
		<input type="password" id="password"><br>
		<input type="button" value="Submit" onclick="ajax_method('http://127.0.0.1/tradWebAPI/adminLogin.php', adminLogin())">
	</form>

</body>
</html>